package com.jp.knowledge.animation;

import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.Transformation;

/**
 * 头条详情竞一下图标动画
 * Created by 528787067@qq.com on 2017/1/15.
 */

public class JingIconAnimation extends Animation {

    private int radius;

    public JingIconAnimation(long duration, int radius) {
        setDuration(duration);
        setRepeatCount(Integer.MAX_VALUE);
        setInterpolator(new LinearInterpolator());
        this.radius = radius;
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        t.getMatrix().setTranslate((float) (radius * Math.cos(2*Math.PI*interpolatedTime)),
                (float)(radius * Math.sin(2*Math.PI*interpolatedTime)));
    }
}
